import network_utils from '../../../../http/NetworkUtils';
const constants = require('../../../../common/Constants.js');
import * as util from '../../../../utils/UmfUtils.js';
const umfDialog = require('../../../../utils/UmfDialog.js');
const PageRouter = require('../../../../utils/PageRouter.js');
import UmfLog from '../../../../utils/UmfLog';


let inputValue = null;
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    bankListArray: []
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let res = app.globalData.systemInfo;
    this.setData({
      deviceW: res.windowWidth,
      deviceH: res.windowHeight
    })
  },

  bindKeyInput: function (e) {
    inputValue = util.removeSpace(e.detail.value);
  },

  bankCellClick: function (e) {
    UmfLog.log(e.currentTarget.dataset.current);
    PageRouter.navigateBack({
      delta: 1,
      data: e.currentTarget.dataset.current["binbankname"]
    })
  },
  //查询按钮
  queryClick: function () {

    if (inputValue && inputValue.length > 0) {
      this._requestBankData(inputValue);
    } else {
      umfDialog.show("请输入银行名称", () => {

      });
    }
  },

  //银行名称网络请求

  _requestBankData: function (queryData) {
    let params = {
      pageNum: "1",
      pageSize: "2000",
      binbankname: queryData
    };
    network_utils.buildRequest(constants.Interfaces.FUNC_QUERY_BANKLIST, params, {
      doHttpSucess: (response) => {
        if (constants.RetCodes.SUCCESS === response.retCode) {
          this.setData({
            bankListArray: response["listStr"]
          });
          return true;
        }
        return false;
      }
    }).send();
  },
})